{% extends "base.html" %}

{% block css %}
<link rel="stylesheet" type="text/css" href="/statics/css/booking.css" />
{% endblock %}

{% block javascript %}
<script type="text/javascript" src="/statics/javascript/booking.js"></script>
<script type="text/javascript">
	function refreshDish(){
	    if($("#shop_select").val()!=null){
	        $.get("/booking/dish/" + $("#shop_select").val(),{},  function(data){
	            $('#dish_body').children().remove();
	            $('#dish_body').append(data);
	        }, 'html');
	    }
	}

	function order(){
		if(document.getElementById("emp_id").value==""){
			showMessage("请输入员工号");
		}else if(document.getElementById("emp_name").value==""){
			showMessage("请输入员工姓名");
		}else{
			document.forms[0].submit();
		}
	}


    $(function(){
        $("#shop_select").change(function(){
            $.get("/booking/dish/"+$(this).val(),  
             function(data){
                $("#dish_body").html(data);
             }, 'html');
         });
         
         $('#emp_id').blur(function(){
            $.get('/user/' + $(this).val(), {}, function(data){
                var data = $.xml2json(data);
                if(data.error){
                    
                } else {
                    $('#emp_name').val(data);
                }
            }, 'xml');
         });

        refreshDish();
    });
</script>
{% endblock %}

{% block title %}我要订饭{% endblock %}

{% block content %}
<p>今天是:<b>{% now "Y年n月j日(l)"%}</b></p>
    <form id="add_task_form" action="." method="POST">
        <p>
            <label for="emp_id">员工编号:</label>
            <input id="emp_id" name="emp_code" size="10"/>
        </p>
        <p>
            <label for="emp_name">员工姓名:</label>
            <input id="emp_name" name="emp_name" size="20"/>
        </p>
    
        <p>
            <label for="shop_select">选择店铺:</label>
            <select id="shop_select" name="shop_key">
            {% if shops %}
                {% for shop in shops %}
                    <option value="{{ shop.key }}">{{ shop.name }}</option>
                {% endfor %}
            {% endif %}
            </select>
        </p>
        <p>
		<table clas="dish_table"  border="1" style="border-collapse: collapse">
		  <col width="40"/>
		  <col width="150"/>
		  <col width="150"/>
		<thead>
		<tr><th>选择</th><th>菜名</th><th>价格</th></tr>
		</thead>
		<tbody id="dish_body">
		
		</tbody>
		</table>
        </p>
        <p>
           <!--<input type="submit" value="提交"/>-->
           <input type="button" onclick="order();" value="提交"/>
        </p>
    </form>
{% endblock %}